cmake_minimum_required(VERSION 3.10)
project(vio_bag_sim)

set(CMAKE_CXX_FLAGS "-std=c++14 -march=native")

set(CMAKE_BUILD_TYPE Release)

# suppress opengl warning
set(OpenGL_GL_PREFERENCE GLVND)

# OpenCV 4
find_package(OpenCV 4 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

# Boost
find_package(Boost REQUIRED)
find_package(Boost COMPONENTS filesystem thread REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

# glog
find_package(glog 0.6.0 REQUIRED)
include_directories(${GLOG_INCLUDE_DIR})

# pangolin
find_package(Pangolin REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})

# Sophus
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})

# fmt
find_package(fmt REQUIRED)

# g2o
find_package(g2o REQUIRED)
include_directories(${G2O_INCLUDE_DIRS})

# gtsam
find_package(GTSAM REQUIRED)
include_directories(${GTSAM_INCLUDE_DIR})

# Eigen
include_directories("/usr/include/eigen3")

find_package(fast REQUIRED)
include_directories(${fast_INCLUDE_DIRS})

# ros
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  geometry_msgs
  image_transport
  roscpp
  rosbag
  sensor_msgs
  std_msgs
)
include_directories(
  ${PROJECT_SOURCE_DIR}
  ${catkin_INCLUDE_DIRS}
)

set(THIRD_PARTY_LIBS
  ${catkin_LIBRARIES}
  ${OpenCV_LIBS}
  ${fast_LIBRARIES}
  ${Sophus_LIBRARIES}
  ${Pangolin_LIBRARIES}
  glog::glog
  g2o_core g2o_stuff
  gtsam
  fmt::fmt
)

# vio algorithm
add_subdirectory(vio)

# vio bag simulation
add_library(vio_bag_sim vio_bag_sim.cc)
target_link_libraries(vio_bag_sim ${THIRD_PARTY_LIBS} vio_isam2)

# simulation
add_executable(main_sim main_sim.cc)
target_link_libraries(main_sim vio_bag_sim)
